package com.gitee.wsl.struct.tree.ext

import com.gitee.wsl.struct.tree.Tree
import com.gitee.wsl.struct.tree.TreeElement

operator fun <T,E: TreeElement<T, E>> Tree<T, E>.contains(data:T) = find(data) != null

fun<T,E: TreeElement<T, E>> TreeElement<T, E>.isChildContains(child:TreeElement<T, E>):Boolean{
    if( this == child ) return false
    var path :TreeElement<T, E>? = child.parent
    while (path!=null){
        if(this == path) return true
        path = path.parent
    }
    return false
}